package org.ru.mse10.cvis.web.model;

import java.util.ArrayList;
import java.util.List;

import org.ru.mse10.cvis.entity.cv.custom.CustomField;
import org.ru.mse10.cvis.entity.util.CustomFieldValueProviderType;
import org.ru.mse10.cvis.util.CommonUtil;

/**
 * The Class CustomFieldValueProviderUIModel.
 */
public class CustomFieldValueProviderUIModel extends UIModel<CustomField> {

	/** The identifier. */
	private String identifier;

	/** The display name. */
	private String displayName;

	/** The description. */
	private String description;

	// values for provider using a static list
	/** The static list. */
	private List<String> staticList = new ArrayList<String>();

	// WS provider
	/** The wsdl location. */
	private String wsdlLocation;

	/** The operation. */
	private String operation;

	// Codelist provider
	/** The codelist code. */
	private String codelistCode;

	// misc
	/** The static list value. */
	private String staticListValue;

	/** The value provider type. */
	private CustomFieldValueProviderType valueProviderType = CustomFieldValueProviderType
			.getDefault();

	/**
	 * Instantiates a new custom field value provider ui model.
	 * 
	 * @param modelObject
	 *            the model object
	 */
	public CustomFieldValueProviderUIModel(CustomField modelObject) {
		super(modelObject);
	}

	// -------------- actions

	/**
	 * Action add to static list.
	 */
	public void actionAddToStaticList() {
		if (!CommonUtil.isEmpty(getStaticListValue())) {
			getStaticList().add(getStaticListValue());
			setStaticListValue(null);
		}
	}

	// -------------- get/set

	/**
	 * Checks if is static list data provider.
	 * 
	 * @return true, if is static list data provider
	 */
	public boolean isStaticListDataProvider() {
		return getValueProviderType() == CustomFieldValueProviderType.STATIC_LIST;
	}

	/**
	 * Checks if is wS data provider.
	 * 
	 * @return true, if is wS data provider
	 */
	public boolean isWSDataProvider() {
		return getValueProviderType() == CustomFieldValueProviderType.WS;
	}

	/**
	 * Checks if is codelist data provider.
	 * 
	 * @return true, if is codelist data provider
	 */
	public boolean isCodelistDataProvider() {
		return getValueProviderType() == CustomFieldValueProviderType.CL;
	}

	/**
	 * Gets the identifier.
	 * 
	 * @return the identifier
	 */
	public String getIdentifier() {
		return identifier;
	}

	/**
	 * Sets the identifier.
	 * 
	 * @param identifier
	 *            the new identifier
	 */
	public void setIdentifier(String identifier) {
		this.identifier = identifier;
	}

	/**
	 * Gets the display name.
	 * 
	 * @return the display name
	 */
	public String getDisplayName() {
		return displayName;
	}

	/**
	 * Sets the display name.
	 * 
	 * @param displayName
	 *            the new display name
	 */
	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}

	/**
	 * Gets the description.
	 * 
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * Sets the description.
	 * 
	 * @param description
	 *            the new description
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * Gets the static list.
	 * 
	 * @return the static list
	 */
	public List<String> getStaticList() {
		return staticList;
	}

	/**
	 * Sets the static list.
	 * 
	 * @param staticList
	 *            the new static list
	 */
	public void setStaticList(List<String> staticList) {
		this.staticList = staticList;
	}

	/**
	 * Gets the wsdl location.
	 * 
	 * @return the wsdl location
	 */
	public String getWsdlLocation() {
		return wsdlLocation;
	}

	/**
	 * Sets the wsdl location.
	 * 
	 * @param wsdlLocation
	 *            the new wsdl location
	 */
	public void setWsdlLocation(String wsdlLocation) {
		this.wsdlLocation = wsdlLocation;
	}

	/**
	 * Gets the operation.
	 * 
	 * @return the operation
	 */
	public String getOperation() {
		return operation;
	}

	/**
	 * Sets the operation.
	 * 
	 * @param operation
	 *            the new operation
	 */
	public void setOperation(String operation) {
		this.operation = operation;
	}

	/**
	 * Gets the static list value.
	 * 
	 * @return the static list value
	 */
	public String getStaticListValue() {
		return staticListValue;
	}

	/**
	 * Sets the static list value.
	 * 
	 * @param staticListValue
	 *            the new static list value
	 */
	public void setStaticListValue(String staticListValue) {
		this.staticListValue = staticListValue;
	}

	/**
	 * Gets the value provider type.
	 * 
	 * @return the value provider type
	 */
	public CustomFieldValueProviderType getValueProviderType() {
		return valueProviderType;
	}

	/**
	 * Sets the value provider type.
	 * 
	 * @param valueProviderType
	 *            the new value provider type
	 */
	public void setValueProviderType(
			CustomFieldValueProviderType valueProviderType) {
		this.valueProviderType = valueProviderType;
	}

	/**
	 * Gets the codelist code.
	 * 
	 * @return the codelist code
	 */
	public String getCodelistCode() {
		return codelistCode;
	}

	/**
	 * Sets the codelist code.
	 * 
	 * @param codelistCode
	 *            the new codelist code
	 */
	public void setCodelistCode(String codelistCode) {
		this.codelistCode = codelistCode;
	}

}
